﻿using B.MESUI.Login.A_Public;
using B.MESUI.Login.BasicData_UI;
using B.MESUI.Login.BasicData_UI.Customer;
using B.MESUI.Login.BasicData_UI.Supplier;
using B.MESUI.Login.BasicData_UI.WorkStation;
using B.MESUI.Login.EquipmentManagement.DeviceLedgerService;
using B.MESUI.Login.EquipmentManagement.DeviceTypeService;
using B.MESUI.Login.EquipmentManagement.ToolingFixturesService;
using B.MESUI.Login.ProdManagement.From.排班;
using B.MESUI.Login.ProdManagement.Lock;
using B.MESUI.Login.WareHouseManage.Externallabel;
using B.MESUI.Login.WareHouseManage.IOWareHouse;
using B.MESUI.Login.WareHouseManage.LocationTest;
using B.MESUI.Login.WareHouseManage.WareHouseArea;
using B.MESUI.Login.WareHouseManage.WareHouseLocation;
using B.MESUI.Login.WareHouseManage.成品;
using B.MESUI.Login.WorkflowCore.Definition;
using B.MESUI.Login.WorkflowCore.Instance;
using B.MESUI.Login.WorkflowCore.MyAudit;
using DevExpress.XtraBars;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace B.MESUI.Login
{
    public partial class MainMenu : DevExpress.XtraBars.Ribbon.RibbonForm
    {
        public MainMenu()
        {
            InitializeComponent();
        }

        private void add(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            bool result = false;
            //遍历所有子窗体，找到已经打开的子窗体，并显示拒绝重复打开
            foreach (var item in this.MdiChildren)
            {
                if (item.Text == e.Link.Caption)
                {
                    item.Activate();
                    result = true;
                    break;
                }
            }
            if (!result)
            {
                XtraForm1 xtraUserControl1 = new XtraForm1();
                xtraUserControl1.MdiParent = this;
                xtraUserControl1.Show();
            }
        }

        private void DeviceType(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            bool result = false;
            //遍历所有子窗体，找到已经打开的子窗体，并显示拒绝重复打开
            foreach (var item in this.MdiChildren)
            {
                if (item.Text == e.Link.Caption)
                {
                    item.Activate();
                    result = true;
                    break;
                }
            }
            if (!result)
            {
                DeviceTypeForm baseset = new DeviceTypeForm();
                baseset.MdiParent = this;
                baseset.Show();
            }
        }

        private void WorkShop(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            bool result = false;
            //遍历所有子窗体，找到已经打开的子窗体，并显示拒绝重复打开
            foreach (var item in this.MdiChildren)
            {
                if (item.Text == e.Link.Caption)
                {
                    item.Activate();
                    result = true;
                    break;
                }
            }
            if (!result)
            {
                WorkShop workShop = new WorkShop();
                workShop.MdiParent = this;
                workShop.Show();
            }
        }

        private void GetDefinitionList(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            bool result = false;
            //遍历所有子窗体，找到已经打开的子窗体，并显示拒绝重复打开
            foreach (var item in this.MdiChildren)
            {
                if (item.Text == e.Link.Caption)
                {
                    item.Activate();
                    result = true;
                    break;
                }
            }
            if (!result)
            {
                WareHouseDefinitionForm definitionForm = new WareHouseDefinitionForm();
                definitionForm.MdiParent = this;
                definitionForm.Show();
            }
        }

        private void WorkOrderClick(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            bool result = false;
            //遍历所有子窗体，找到已经打开的子窗体，并显示拒绝重复打开
            foreach (var item in this.MdiChildren)
            {
                if (item.Text == e.Link.Caption)
                {
                    item.Activate();
                    result = true;
                    break;
                }
            }
            if (!result)
            {
                YSL definitionForm = new YSL();
                definitionForm.MdiParent = this;
                definitionForm.Show();
            }

        }

        private void GetAreaList(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            bool result = false;
            //遍历所有子窗体，找到已经打开的子窗体，并显示拒绝重复打开
            foreach (var item in this.MdiChildren)
            {
                if (item.Text == e.Link.Caption)
                {
                    item.Activate();
                    result = true;
                    break;
                }
            }
            if (!result)
            {
                WareHouseAreaForm areaForm = new WareHouseAreaForm();
                areaForm.MdiParent = this;
                areaForm.Show();
            }
        }

        private void XKYBarItem3_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            bool result = false;
            //遍历所有子窗体，找到已经打开的子窗体，并显示拒绝重复打开
            foreach (var item in this.MdiChildren)
            {
                if (item.Text == e.Link.Caption)
                {
                    item.Activate();
                    result = true;
                    break;
                }
            }
            if (!result)
            {
                ShowDeviceLedgerForm deviceledger = new ShowDeviceLedgerForm();
                deviceledger.MdiParent = this;
                deviceledger.Show();
            }
        }

        private void ProductLock(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            bool result = false;
            //遍历所有子窗体，找到已经打开的子窗体，并显示拒绝重复打开
            foreach (var item in this.MdiChildren)
            {
                if (item.Text == e.Link.Caption)
                {
                    item.Activate();
                    result = true;
                    break;
                }
            }
            if (!result)
            {
                ProductLockForm locks = new ProductLockForm();
                locks.MdiParent = this;
                locks.Show();
            }
        }

        private void Unlock(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            bool result = false;
            //遍历所有子窗体，找到已经打开的子窗体，并显示拒绝重复打开
            foreach (var item in this.MdiChildren)
            {
                if (item.Text == e.Link.Caption)
                {
                    item.Activate();
                    result = true;
                    break;
                }
            }
            if (!result)
            {
                UnProductLockForm unlock = new UnProductLockForm();
                unlock.MdiParent = this;
                unlock.Show();
            }
        }

        private void ProjectLineClick(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            bool result = false;
            //遍历所有子窗体，找到已经打开的子窗体，并显示拒绝重复打开
            foreach (var item in this.MdiChildren)
            {
                if (item.Text == e.Link.Caption)
                {
                    item.Activate();
                    result = true;
                    break;
                }
            }
            if (!result)
            {
                GetProjectLineForm unlock = new GetProjectLineForm();
                unlock.MdiParent = this;
                unlock.Show();
            }
        }

        private void WareHouseLocation_Load(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            bool result = false;
            //遍历所有子窗体，找到已经打开的子窗体，并显示拒绝重复打开
            foreach (var item in this.MdiChildren)
            {
                if (item.Text == e.Link.Caption)
                {
                    item.Activate();
                    result = true;
                    break;
                }
            }
            if (!result)
            {
                LocationForm unlock = new LocationForm();
                unlock.MdiParent = this;
                unlock.Show();
            }
        }

        private void Station_ListClick(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            bool result = false;
            //遍历所有子窗体，找到已经打开的子窗体，并显示拒绝重复打开
            foreach (var item in this.MdiChildren)
            {
                if (item.Text == e.Link.Caption)
                {
                    item.Activate();
                    result = true;
                    break;
                }
            }
            if (!result)
            {
                GetStationForm unlock = new GetStationForm();
                unlock.MdiParent = this;
                unlock.Show();
            }
        }

        private void XKYBarItem4_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            bool result = false;
            //遍历所有子窗体，找到已经打开的子窗体，并显示拒绝重复打开
            foreach (var item in this.MdiChildren)
            {
                if (item.Text == e.Link.Caption)
                {
                    item.Activate();
                    result = true;
                    break;
                }
            }
            if (!result)
            {
                ShowToolingFixtures unlock = new ShowToolingFixtures();
                unlock.MdiParent = this;
                unlock.Show();
            }
        }

        private void CustomBarItem7_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            bool result = false;
            //遍历所有子窗体，找到已经打开的子窗体，并显示拒绝重复打开
            foreach (var item in this.MdiChildren)
            {
                if (item.Text == e.Link.Caption)
                {
                    item.Activate();
                    result = true;
                    break;
                }
            }
            if (!result)
            {
                GetCustomerForm unlock = new GetCustomerForm();
                unlock.MdiParent = this;
                unlock.Show();
            }
        }

        private void FLHBarItem7_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            bool result = false;
            //遍历所有子窗体，找到已经打开的子窗体，并显示拒绝重复打开
            foreach (var item in this.MdiChildren)
            {
                if (item.Text == e.Link.Caption)
                {
                    item.Activate();
                    result = true;
                    break;
                }
            }
            if (!result)
            {
                ExternallabelForm unlock = new ExternallabelForm();
                unlock.MdiParent = this;
                unlock.Show();
            }
        }

        private void FLHBarItem8_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            bool result = false;
            //遍历所有子窗体，找到已经打开的子窗体，并显示拒绝重复打开
            foreach (var item in this.MdiChildren)
            {
                if (item.Text == e.Link.Caption)
                {
                    item.Activate();
                    result = true;
                    break;
                }
            }
            if (!result)
            {
                IOWareHouseForm unlock = new IOWareHouseForm();
                unlock.MdiParent = this;
                unlock.Show();
            }
        }

        private void navBarItem2_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            bool result = false;
            //遍历所有子窗体，找到已经打开的子窗体，并显示拒绝重复打开
            foreach (var item in this.MdiChildren)
            {
                if (item.Text == e.Link.Caption)
                {
                    item.Activate();
                    result = true;
                    break;
                }
            }
            if (!result)
            {
                EncoderForm unlock = new EncoderForm();
                unlock.MdiParent = this;
                unlock.Show();
            }
        }

        private void navBarItem6_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            bool result = false;
            //遍历所有子窗体，找到已经打开的子窗体，并显示拒绝重复打开
            foreach (var item in this.MdiChildren)
            {
                if (item.Text == e.Link.Caption)
                {
                    item.Activate();
                    result = true;
                    break;
                }
            }
            if (!result)
            {
                DashboardForm unlock = new DashboardForm();
                unlock.MdiParent = this;
                unlock.Show();
            }
        }

        private void SuppilerBarItem8_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            bool result = false;
            //遍历所有子窗体，找到已经打开的子窗体，并显示拒绝重复打开
            foreach (var item in this.MdiChildren)
            {
                if (item.Text == e.Link.Caption)
                {
                    item.Activate();
                    result = true;
                    break;
                }
            }
            if (!result)
            {
                GetSupplierForm unlock = new GetSupplierForm();
                unlock.MdiParent = this;
                unlock.Show();
            }
        }

        private void navBarItem3_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            bool result = false;
            //遍历所有子窗体，找到已经打开的子窗体，并显示拒绝重复打开
            foreach (var item in this.MdiChildren)
            {
                if (item.Text == "设计审批流程")
                {
                    item.Activate();
                    result = true;
                    break;
                }
            }
            if (!result)
            {
                var unlock = new ShowDefinition();
                unlock.MdiParent = this;
                unlock.Show();
            }
        }

        private void chengpin_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            bool result = false;
            //遍历所有子窗体，找到已经打开的子窗体，并显示拒绝重复打开
            foreach (var item in this.MdiChildren)
            {
                if (item.Text == e.Link.Caption)
                {
                    item.Activate();
                    result = true;
                    break;
                }
            }
            if (!result)
            {
                var unlock = new Made_UpForm();
                unlock.MdiParent = this;
                unlock.Show();
            }
        }

        private void navBarItem9_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            bool result = false;
            //遍历所有子窗体，找到已经打开的子窗体，并显示拒绝重复打开
            foreach (var item in this.MdiChildren)
            {
                if (item.Text == e.Link.Caption)
                {
                    item.Activate();
                    result = true;
                    break;
                }
            }
            if (!result)
            {
                var unlock = new GanttChartForm();
                unlock.MdiParent = this;
                unlock.Show();
            }
        }

        private void simpleButton1_Click(object sender, EventArgs e)
        {
            this.Close();
            Login login = new Login();
            login.Show();
        }

        private void navBarItem4_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            bool result = false;
            //遍历所有子窗体，找到已经打开的子窗体，并显示拒绝重复打开
            foreach (var item in this.MdiChildren)
            {
                if (item.Text == "流程实例")
                {
                    item.Activate();
                    result = true;
                    break;
                }
            }
            if (!result)
            {
                var unlock = new ShowInstance();
                unlock.MdiParent = this;
                unlock.Show();
            }
        }

        private void navBarItem7_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            bool result = false;
            //遍历所有子窗体，找到已经打开的子窗体，并显示拒绝重复打开
            foreach (var item in this.MdiChildren)
            {
                if (item.Text == "待审批流程")
                {
                    item.Activate();
                    result = true;
                    break;
                }
            }
            if (!result)
            {
                var unlock = new ShowMyAudit();
                unlock.MdiParent = this;
                unlock.Show();
            }
        }

    }
}